
/**
 * Created by Zhao Bo En on 2017/12/30.
 */

//日期转换
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
var WfMetSk10 = null;//测风塔数据表
var WfMetSk30 = null;//测风塔数据表
var WfMetSk50 = null;//测风塔数据表
var WfMetSk70 = null;//测风塔数据表
var WfMetSk80 = null;//测风塔数据表
var startTime = null;       //开始时间，表格导出数据使用
var endTime = null;         //结束时间，表格导出数据使用
var farmName = null;       //电场名称，表格导出数据使用
var fileName = null;

$(function () {
    //$.ajaxSettings.async = false;
    loadTower();//加载测风塔
    showDiv();
    dateTiemSelect();
    $("#query").click(function () {
        // alert("111");
        if($("#startTime").val()===""){
            layer.msg("输入开始时间！", {icon: 2});
            $("#endTime").val("");
        }
        var startTime = new Date($("#startTime").val().replace(/\-/g, "\/"));
        var endTime = new Date($("#endTime").val().replace(/\-/g, "\/"));
        if(startTime >=endTime){
            layer.msg("开始时间不能大于结束时间！", {icon: 2});
            $("#startTime").val("");
            $("#endTime").val("");
            return false;
        }else {
            load();
        }
    })

    var aa = $('#selectFarm', window.parent.document).find("option:selected").text();
    console.log(aa);
    //  fileName = aa.substring(31,aa.length);
    // console.log(fileName);
    startTime = $("#startTime").val();
    endTime = $("#endTime").val();

    var table = new tableFactory(startTime,endTime,aa);
})

//点击时间查询
function dateTiemSelect(){
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#startTime', //新增的日期
            type: 'date',//日期类型date表示年月日
            /*  trigger: 'click',//如果绑定的元素非输入框，则默认事件为：click*/
            theme: '#071f3a',//自定义主题
            min: '2014-1-1',//限制最小日期
            max: '2028-12-31'//限制最大日期
        });
        laydate.render({
            elem: '#endTime', //新增的日期
            type: 'date',
            theme: '#071f3a',//自定义主题
            max: '2028-12-31',//限制最大日期
            ready: function(date){
                //console.log(date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
            },
            /*change: function(value, date, endDate){ //日期时间被切换后的回调
                console.log(value); //得到日期生成的值，如：2017-08-18
                console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
            }*/
            done: function(value, date, endDate){//选中之后的对调函数
                //得到日期生成的值，如：2017-08-18
                // console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                //console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
            }
        });
    });
}

function loadTower(){
    $("#tower").empty();//赋值之前，先清空
    var me = this;
    var index = layer.load(1);
    var farmid = $('#selectFarm', window.parent.document).val();
    var news = $("#tower");//获取测风塔对象
    var data = {"farmid":farmid};
    $.ajax({
        url : "../windCurvesManage/getTower",
        type : "get",
        async:false,
        contentType : "application/json",
        dataType : "json",
        data :data /*JSON.stringify(data)*/,//转换成字符串。后台使用了RequestBody注解
        success : function(data) {
            if(data.listTowerno.length>0){
                for(var i = 0;i<data.listTowerno.length;i++){
                    if(data.listTowerno[i] == data.thisTowerno){
                        news.append('<option value="'+data.listTowerno[i]+'" selected = "selected">'+data.listTowermodel[i]+'</option>');
                    }else {
                        news.append('<option value="'+data.listTowerno[i]+'">'+data.listTowermodel[i]+'</option>');
                    }
                }

            }else {
                news.append('<option value="'+404404404+'">'+'无'+'</option>');
            }


            $("#tower").selectpicker('refresh');
            load();
            layer.close(index);
        }
    });
    $("#tower").selectpicker();
}


//初始化加载曲线跟表格数据
function load(){
    var index = layer.load(1);
    var date = new Array();//观测时间
    var wfmetsk = new Array();
    var windspeed = new Array();
    var windspeed10 = new Array();
    var windspeed30 = new Array();
    var windspeed50 = new Array();
    var windspeed70 = new Array();
    var windspeed80 = new Array();
    var id=$("#cf option:selected");//获取id为"cf"的选项
    var tower = $("#tower option:checked").val();
    var farmid = $('#selectFarm', window.parent.document).val();//获取父页面的元素
    var p = {
        "startTime":$("#startTime").val(),
        "endTime":$("#endTime").val(),
        "farmid":farmid,
        "towerid":tower,
    };
    $.ajax({
        url : "../roseManage/selectAllForTime",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p/*JSON.stringify(p)*/,//转换成字符串。后台使用了RequestBody注解
        success : function(data) {
            WfMetSk10 = data.wfList10;
            WfMetSk30 = data.wfList30;
            WfMetSk50 = data.wfList50;
            WfMetSk70 = data.wfList70;
            WfMetSk80 = data.wfList80;
            var wendu ;
            var wenduvalue= new Array();
            if(id.val() == 1){
                if(data.wfList10.length>0){
                    $.each(data.wfList10, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        var s = {Observetime:time,Temp:item.temp,Humidity:item.humidity,Preessure:item.preessure};
                        wfmetsk.push(s)
                        wenduvalue.push({name:time,value:[time,item.temp]});
                        wendu = '温度(℃)';
                    });
                }

                if(data.wfList.length>0){
                    $.each(data.wfList, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });

                }
                $("#historicalData").bootstrapTable("load", wfmetsk);
                lodaTu(wendu,wenduvalue);
            }else if(id.val() == 2){
                if(data.wfList10.length>0){
                    $.each(data.wfList10, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        var s = {Observetime:time,Temp:item.temp,Humidity:item.humidity,Preessure:item.preessure};
                        wfmetsk.push(s)
                        wenduvalue.push({name:time,value:[time,item.humidity]});
                        wendu = '湿度(%)';
                    });
                }

                if(data.wfList.length>0){
                    $.each(data.wfList, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });

                }
                $("#historicalData").bootstrapTable("load", wfmetsk);
                lodaTu(wendu,wenduvalue);

            }else if(id.val() == 3){
                if(data.wfList10.length>0){
                    $.each(data.wfList10, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        var s = {Observetime:time,Temp:item.temp,Humidity:item.humidity,Preessure:item.preessure};
                        wfmetsk.push(s)
                        wenduvalue.push({name:time,value:[time,item.preessure]});
                        wendu = '气压(hPa)';
                    });
                }

                if(data.wfList.length>0){
                    $.each(data.wfList, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });

                }
                $("#historicalData").bootstrapTable("load", wfmetsk);
                lodaTu(wendu,wenduvalue);

            }else if(id.val() == 4){
                if(data.wfList10.length>0){
                    $.each(data.wfList10, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        var s = {Observetime:time,Temp:item.temp,Humidity:item.humidity,Preessure:item.preessure};
                        wfmetsk.push(s)

                        if(item.windspeed!=null ){
                            windspeed10.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });
                }
                if(data.wfList30.length>0){
                    $.each(data.wfList30, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed30.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });
                }
                if(data.wfList50.length>0){
                    $.each(data.wfList50, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed50.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });
                }
                if(data.wfList70.length>0){
                    $.each(data.wfList70, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed70.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });
                }
                if(data.wfList80.length>0){
                    $.each(data.wfList80, function (index, item) {
                        var time = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm");
                        if(item.windspeed!=null ){
                            windspeed80.push({name:time,value:[time,item.windspeed.toFixed(2)]});//天气风速
                        }
                    });
                }
                $("#historicalData").bootstrapTable("load", wfmetsk);
                lodaTu2(windspeed10,windspeed30,windspeed50,windspeed70,windspeed80);
            }

            layer.close(index);
        },
    });

}




//表格工厂
function tableFactory(startTime,endTime,fileNames) {
    var me = this;
    me.data = null;//有功功率
    me.windData = null;//电站信息
    var init = function () {
        $.when(me.getWindData()).then(function () {
            $("#historicalData").bootstrapTable({
                method: 'get',				  //请求方式（*）
                striped: true,					  //是否显示行间隔色
                cache: false,					   //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,				   //是否显示分页（*）
                sortable: true,					 //是否启用排序
                sortOrder: "desc",				   //排序方式
                sidePagination: "client",		   //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,					   //初始化加载第一页，默认第一页
                search: true,					   //是否显示表格搜索，只能进行客户端搜索
                strictSearch: false,                //true为全匹配，false为模糊查询
                showColumns: true,				  //是否显示筛选列按钮
                showRefresh: true,			  //是否显示刷新按钮
                clickToSelect:true,				//是否启用点击选中行
                showToggle: false,					//是否显示详细视图和列表视图的切换按钮
                cardView: false,					//是否显示详细视图
                detailView: false,				   //是否显示父子表
                singleSelect: true,                //是否支持多选,false表示支持多选，true表示不支持
                //undefinedText: '_',              //当数据为undefined时显示的字符
                height: 'auto',
                pageSize: 20,
                pageList: [5,20,30],
                editable:true,//是否可以行内编辑
                showExport: true,//是否显示导出按钮
                exportDataType:'all',//导出全部
                exportTypes:[  'csv'], //导出文件类型
                export: 'glyphicon-export icon-share',
                exportOptions:{
                    // ignoreColumn: [0,1],  //忽略某一列的索引
                    fileName:startTime+"_"+endTime+"_"+fileNames,  //文件名称设置
                    // worksheetName: 'sheet1',  //表格工作区名称
                    // tableName: '总台帐报表',
                    //  excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
                    // onMsoNumberFormat: DoOnMsoNumberFormat
                },
                columns: [{
                    title: '时间',
                    field: 'Observetime',
                    sortable: true,//排序
                    align: 'center',
                    valign: 'middle',
                    /*formatter: function (value, row, index) {
                        return new Date(parseInt(value)).Format("yyyy-MM-dd hh:mm");
                    }*/
                },{
                    title: '10m风速(m/s)',
                    field: '',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return me.getWfMetSkSpeed10(row.Observetime);
                    }
                },{
                    title: '30m风速(m/s)',
                    field: '',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return me.getWfMetSkSpeed30(row.Observetime);
                    }
                },{
                    title: '50m风速(m/s)',
                    field: '',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return me.getWfMetSkSpeed50(row.Observetime);
                    }
                },
                    {
                        title: '70m风速(m/s)',
                        field: '',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            return me.getWfMetSkSpeed70(row.Observetime);
                        }
                    },{
                        title: '80m风速(m/s)',
                        field: '',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            return me.getWfMetSkSpeed80(row.Observetime);
                        }
                    },
                    {
                        title: '温度(℃)',
                        field: 'Temp',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            if(value == null){
                                return "-";
                            }else {
                                return value.toFixed(2);
                            }

                        }
                    }, {
                        title: '湿度(%)',
                        field: 'Humidity',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            if(value == null){
                                return "-";
                            }else {
                                return value.toFixed(2);
                            }
                        }
                    },
                    {
                        title: '气压(hPa)',
                        field: 'Preessure',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            if(value == null){
                                return "-";
                            }else {
                                return value.toFixed(2);
                            }
                        }
                    }
                ],
                onEditableSave: function (field, row, oldValue, $el) {//编辑之后的事件
                    var p ={
                        id:row.fid,
                        power:row.power
                    }
                    $.ajax({
                        type: "post",
                        url: "../shortPeriodManage/edit",
                        data:p,//后台使用了实体类，前台就不能用Json.stringify
                        dataType: 'JSON',
                        success: function (data, status) {

                        },
                        error: function () {
                            alert('编辑失败');
                        },
                        complete: function () {

                        }
                    });
                }
            });
            //me.loadData();
            load();
        });
    }
    init();
}
tableFactory.prototype = {
    loadData: function () {
        var me = this;
        var index = layer.load(1);
        $.getJSON('../shortPeriodManage/selectAll', '', function (_data) {
            me.data = _data;
            $("#historicalData").bootstrapTable("load", _data);
            layer.close(index);
        })
    },
    //加载电站信息
    getWindData:function () {
        var me = this;
        $.getJSON('../windManage/selectAll', '', function (_data) {
            me.WindData = _data;
        })
    },
    getWindById: function (farmid) {
        var farmName = '';
        var me = this;
        $.each(me.WindData, function (index, item) {
            if (item.farmid === farmid) {
                farmName = item.farmname;
                return false;
            }
        });
        return farmName;
    },
    /*获取10m测风塔风速*/
    getWfMetSkSpeed10:function (time) {
        var speed="";
        if(WfMetSk10.length>0){
            $.each(WfMetSk10, function (index, item) {
                var WfMetSkTime = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm")
                if(WfMetSkTime==time) {
                    if(item.windspeed!=null){
                        speed = item.windspeed.toFixed(2);
                    }else {
                        speed = "-";
                    }
                    return false;
                }
            });
            return speed;
        }
    },
    /*获取30m测风塔风速*/
    getWfMetSkSpeed30:function (time) {
        var speed="";
        if(WfMetSk30.length>0){
            $.each(WfMetSk30, function (index, item) {
                var WfMetSkTime = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm")
                if(WfMetSkTime==time) {
                    if(item.windspeed!=null){
                        speed = item.windspeed.toFixed(2);
                    }else {
                        speed = "-";
                    }
                    return false;
                }
            });
            return speed;
        }
    },
    /*获取50m测风塔风速*/
    getWfMetSkSpeed50:function (time) {
        var speed="";
        if(WfMetSk50.length>0){
            $.each(WfMetSk50, function (index, item) {
                var WfMetSkTime = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm")
                if(WfMetSkTime==time) {
                    if(item.windspeed!=null){
                        speed = item.windspeed.toFixed(2);
                    }else {
                        speed = "-";
                    }
                    return false;
                }
            });
            return speed;
        }
    },
    /*获取70m测风塔风速*/
    getWfMetSkSpeed70:function (time) {
        var speed="";
        if(WfMetSk70.length>0){
            $.each(WfMetSk70, function (index, item) {
                var WfMetSkTime = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm")
                if(WfMetSkTime==time) {
                    if(item.windspeed!=null){
                        speed = item.windspeed.toFixed(2);
                    }else {
                        speed = "-";
                    }
                    return false;
                }
            });
            return speed;
        }
    },
    /*获取80m测风塔风速*/
    getWfMetSkSpeed80:function (time) {
        var speed="";
        if(WfMetSk80.length>0){
            $.each(WfMetSk80, function (index, item) {
                var WfMetSkTime = new Date(parseInt(item.observetime)).Format("yyyy-MM-dd hh:mm")
                if(WfMetSkTime==time) {
                    if(item.windspeed!=null){
                        speed = item.windspeed.toFixed(2);
                    }else {
                        speed = "-";
                    }
                    return false;
                }
            });
            return speed;
        }
    },

}

function lodaTu(wendu,wenduvalue) {
    var myChart = echarts.init(document.getElementById("main"));
    //vapp.title = '多 X 轴示例';
    var colors = [ '#FFFF00','#FFFF00','#6eb2ff'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            show:true,
            icon: 'rect',
            itemWidth: 25,
            itemHeight: 3,
            itemGap: 13,
            data: ['测风塔风速',wendu],
            textStyle: {
                fontSize: 12,
                fontWeight:'bolder',
                color: '#fff'
            }

        },
        toolbox: {
            show: true,
            feature: {
                saveAsImage: {show: true}
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {
            show: true,
            realtime: true,
            start: 0,
            end: 100
        },
        xAxis: [
            {
                //interval:0,//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [

            {
                splitLine:{show: false},//去除网格线
                name: wendu,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        series: [
            /*{
                name: '测风塔风速',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed,
                itemStyle: {
                    normal: {
                        color:'#A52A2A',
                    }
                },
            },*/
            {
                name: wendu,
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: wenduvalue,
                itemStyle: {
                    normal: {
                        color:'#248f35',
                    }
                },
            }

        ]
    };
    myChart.setOption(option);
}

function lodaTu2(windspeed10,windspeed30,windspeed50,windspeed70,windspeed80) {
    var myChart = echarts.init(document.getElementById("main2"));
    //vapp.title = '多 X 轴示例';
    var colors = [ '#FFFF00','#FFFF00','#6eb2ff'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            show:true,
            icon: 'rect',
            itemWidth: 25,
            itemHeight: 3,
            itemGap: 13,
            data: ['10m风速(m/s)','30m风速(m/s)','50m风速(m/s)','70m风速(m/s)','80m风速(m/s)'],
            textStyle: {
                fontSize: 12,
                fontWeight:'bolder',
                color: '#fff'
            }

        },
        toolbox: {
            show: true,
            feature: {
                saveAsImage: {show: true}
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {
            show: true,
            realtime: true,
            start: 0,
            end: 100
        },
        xAxis: [
            {
                //interval:0,//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [

            {
                splitLine:{show: false},//去除网格线
                name: '风速(m/s)',
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        series: [
            {
                name: '10m风速(m/s)',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed10,
                itemStyle: {
                    normal: {
                        color:'#A52A2A',
                    }
                },
            },{
                name: '30m风速(m/s)',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed30,
                itemStyle: {
                    normal: {
                        color:'#248f35',
                    }
                },
            },{
                name: '50m风速(m/s)',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed50,
                itemStyle: {
                    normal: {
                        color:'#4a6ab5',
                    }
                },
            },
            {
                name: '70m风速(m/s)',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed70,
                itemStyle: {
                    normal: {
                        color:'#458B74',
                    }
                },
            },{
                name: '80m风速(m/s)',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: windspeed80,
                itemStyle: {
                    normal: {
                        color:'#CDBE70',
                    }
                },
            }

        ]
    };
    myChart.setOption(option);
}

function showDiv() {
    $("select").change(function(){
        var selectedValue=$(this).val();

        if(selectedValue==1||selectedValue==2||selectedValue==3){

            $("#main").show();
            $("#main2").hide();
        }
        if(selectedValue==4){

            $("#main2").show();
            $("#main").hide();
        }
    });
}



